<span jwcid="@CenteredMainBorder" title="File Browser">

	<script jwcid="@Script" script="script/fileBrowser.script"/>
	<script jwcid="@Script" script="script/tapestryPrompt.script"/>
	
	<form jwcid="@Form" delegate="ognl:defaultDelegate">
		<span jwcid="directoryHidden@Hidden" value="ognl:currentDirectoryId"/>
		
		<table width="100%">
		
		<tr><td colspan="3">
			<span jwcid="ErrorReporter@ErrorReporter" title="Errors" delegate="ognl:defaultDelegate"/> 
		</td></tr>
		<tr><td colspan="2">
			<a jwcid="addDirectoryDL@DirectLink" parameters="ognl:currentDirectoryId" onclick="return tapestryParameterPrompt('New Folder Name:', '', this)" listener="listener:addFolder">
				<span jwcid="addDirectoryImage@Image" border="0" image="asset:addFolderImage"/></a>
			<a jwcid="addDirectoryDL2@DirectLink" parameters="ognl:currentDirectoryId" onclick="return tapestryParameterPrompt('New Folder Name:', '', this)" listener="listener:addFolder">
				Add Folder
			</a><br>
		</td>
		
		</tr>
		
		<tr><td>
			Upload a file: 
		</td><td>
			<span jwcid="fileUpload@Upload" file="ognl:uploadFile" />
		</td>
		<span  jwcid="moveMediaDropBoxFullIf@If" condition="ognl:moveMediaDropBoxFull()">
			<td rowspan="2">
				<a jwcid="moveToDL2@DirectLink" parameters="ognl:currentDirectoryId" onclick="ognl:'return confirm(\'Are you sure you want to move ' + fileBrowserASO.moveMedia.name + ' to the current directory?  \\nThis action cannot be undone.\')'" listener="listener:moveMedia">
					<span jwcid="moveToImage@Image" border="0" image="asset:moveToImage"/>
				</a>
				<a jwcid="moveToDL@DirectLink" parameters="ognl:currentDirectoryId" onclick="ognl:'return confirm(\'Are you sure you want to move ' + fileBrowserASO.moveMedia.name + ' to the current directory?  \\nThis action cannot be undone.\')'" listener="listener:moveMedia">
					Move <span jwcid="moveFileNameInsert@Insert" value="ognl:fileBrowserASO.moveMedia.name"/><br>
					to current directory
					</a>
			</td>
		</span>
		</tr>
		<tr><td>
		Overwrite: 
		</td><td>
			<span jwcid="overwriteCB@Checkbox" value="ognl:overwrite"/>
		</td></tr>
		<tr><td>
		Rename to: 
		</td><td>
			<span jwcid="filenameTextField@TextField" maxlength="255" value="ognl:fileName"/>
			<input jwcid="uploadSubmit@Submit" label="upload" listener="listener:uploadSubmit"/>
		</td></tr>
            
		<tr><td>
		Current Path: 
		</td><td>
			<span jwcid="currentPathInsert@Insert" value="ognl:currentPath"/>
		</td></tr>	
		<tr><td class="fileBrowserWindow" colspan="3">
				<span jwcid="folderNotRootIf@If" condition="ognl:currentDirectory != null">
					<div class="selectableElement fileBrowserElement">
						<center>
							<a jwcid="cdBackDL@DirectLink" parameters="ognl:currentDirectory.parent == null? null : currentDirectory.parent.id" listener="listener:cd">
								<img jwcid="folderImage2@Image" border="0" image="asset:folderImage"/>
							</a>
							<br>
							<a jwcid="cdBackDL2@DirectLink" parameters="ognl:currentDirectory.parent == null? null : currentDirectory.parent.id" listener="listener:cd">
								...
							</a>
						</center>
					</div>
				</span>
				
				<span jwcid="forEachFolder@For" value="ognl:directory" source="ognl:directoryFolders">
					<div class="selectableElement fileBrowserElement">
					
						<div jwcid="ifDirectoryIsEmpty@If" condition="ognl:(directory.files == null or directory.files.size() == 0) and (directory.children == null or directory.children.size() == 0)" element = "div" class="fileBrowserTool">
							<span jwcid="deleteFolderDL@DirectLink" onclick="return confirm('Are you sure you want to delete this Folder?  This action cannot be undone.')" parameters="ognl:{currentDirectoryId, directory.id}" listener="listener:deleteFolder">
								<span jwcid="deleteImage2@Image" title="Delete" border="0" image="asset:deleteImage"/>
							</span>
							<span jwcid="renameFolderDL@DirectLink" onclick="ognl:'return tapestryParameterPrompt(\'Folder Name:\', \'' + directory.name + '\' , this)'" parameters="ognl:{currentDirectoryId, directory.id}" listener="listener:renameDirectory">
								<span jwcid="renameImage2@Image" title="Rename" border="0" image="asset:renameImage"/>
							</span>
						</div>
						<center>
							<a jwcid="cdDL@DirectLink" parameters="ognl:directory.id" listener="listener:cd">
								<img jwcid="folderImage@Image" title="ognl:directory.name" border="0" image="asset:folderImage"/>
							</a>
							<br>
							<a jwcid="cdDL2@DirectLink" parameters="ognl:directory.id" listener="listener:cd">
								<span jwcid="folderNameInsert@Insert" value="ognl:dotdot(directory.name,7)"/>
							</a>
						</center>
					</div>
				</span>
				
				<span jwcid="forEachMedia@For" value="ognl:media" source="ognl:directoryMedia">
                    <div jwcid="@SelectableDiv" styleClass="selectableElement fileBrowserElement" callback="fileBrowserDialog" value="ognl:'media' + currentPath + media.name ">

						<div class="fileBrowserTool">
							
							<span jwcid="ifImageIsNotReferenced@If" condition="ognl:!isMediaReferenced()">
								<span jwcid="deleteMediaDL@DirectLink" onclick="ognl:'return confirm(\'Are you sure you want to delete \\\'' + media.name + '\\\'?\\nThis action is irreversible.\')'"  parameters="ognl:{currentDirectoryId, media.id}" listener="listener:deleteMedia">
									<span jwcid="deleteImage@Image" title="Delete" border="0" image="asset:deleteImage"/>
								</span>
								<span jwcid="renameMediaDL@DirectLink" parameters="ognl:{currentDirectoryId, media.id}" onclick="ognl:'return tapestryParameterPrompt(\'File Name:\', \'' + media.name + '\' , this)'" listener="listener:renameMedia">
									<span jwcid="renameImage@Image" title="Rename" border="0" image="asset:renameImage"/>
								</span>
								<span jwcid="moveMediaDL@DirectLink" parameters="ognl:{currentDirectoryId, media.id}" listener="listener:startMoveMedia">
									<span jwcid="moveImage@Image" title="Move" border="0" image="asset:moveImage"/>
								</span>
								<br>
							</span>
							
							<span jwcid="viewMediaL@GenericLink" href="ognl: 'media' + currentPath + media.name" target="_blank">
								<span jwcid="viewImage@Image" title="View" border="0" image="asset:previewImage"/>
							</span>
							
						</div>
						
						
						<center>
							
							<img jwcid="mediaImage@Any" title="ognl:media.name" border="0" src="ognl:'images/' + getIconFile()"/>
							
							<br>
							
							<span jwcid="mediaNameInsert@Insert" value="ognl:dotdot(media.name,7)"/>
						</center>
					</div>
				</span>
		</td></tr>
		<tr>
		<td align="left" colspan="2">
		<span class="note">
			*file/folder is uploaded to the current directory<br>
			*file is given the original name if no name is specified<br>
		</span>
		</td><td align="right">
		
		
		<input type="button" onClick="fileBrowserDialog.submit()" value="Submit"/>
		<input type="button" onClick="fileBrowserDialog.cancel()" value="Cancel"/>
		
		</td></tr></table>
		
	</form>

</span>